# coding:utf-8
import time

from lib.base import Base

from page.android import train_list_page, train_fare_adjustment_strategy_page, train_fare_adjustment_page, \
    train_index_page

__author__ = 'weixin.yuan'


class TrainFareAdjustment(Base):
    """补票"""
    def __init__(self, method_name):
        Base.__init__(self, method_name)

        """
        本页元素
        """
        self.question_mark_btn = train_fare_adjustment_page.elements['问号按钮']
        self.before_day_btn = train_fare_adjustment_page.elements['前一天按钮']
        self.next_day_btn = train_fare_adjustment_page.elements['后一天按钮']
        self.earlier_to_lager_btn = train_fare_adjustment_page.elements['出发 早->晚按钮']
        self.high_speed_rail_btn = train_fare_adjustment_page.elements['只看高铁动车按钮']
        self.seat_filter_btn = train_fare_adjustment_page.elements['筛选坐席按钮']

        self.zonghe_filter = train_fare_adjustment_page.elements['zonghe_filter']
        self.commit = train_fare_adjustment_page.elements['确定按钮']

        """
        外部页面元素
        """
        self.search = train_index_page.elements['搜索按钮']
        self.bupiao_btn = train_list_page.elements['补票按钮']
        self.fare_adjustment_strategy_title = train_fare_adjustment_strategy_page.elements['补票攻略title']

    def test_fare_adjustment(self):
        """补票页面check"""
        self.open_schema_android('6003')
        time.sleep(10)
        self.click(self.bupiao_btn)

        self.click(self.question_mark_btn)
        self.check(self.fare_adjustment_strategy_title)
        self.back()

        # self.click(self.next_day_btn)
        # self.click(self.before_day_btn)

        self.click(self.earlier_to_lager_btn)
        self.click(self.high_speed_rail_btn)
        self.click(self.seat_filter_btn)

        for btn in self.zonghe_filter:
            self.click(is_necessary=False, args=self.zonghe_filter[btn], times=5)

        self.click(is_necessary=True, args=self.commit)
